package com.ruoyi.web.controller.basedata;

import com.ruoyi.basedata.domain.ConcentratorCommandLogs;
import com.ruoyi.basedata.service.IConcentratorCommandLogsService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 集中器命令下发日志Controller
 *
 * @author ruoyi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/basedata/concentratorcommandlogs")
public class ConcentratorCommandLogsController extends BaseController
{
    @Autowired
    private IConcentratorCommandLogsService concentratorCommandLogsService;

    /**
     * 查询集中器命令下发日志列表
     */
    @PreAuthorize("@ss.hasAnyPermi('basedata:concentratorcommandlogs:list,basedata:concentrator:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConcentratorCommandLogs concentratorCommandLogs)
    {
        startPage();
        List<ConcentratorCommandLogs> list = concentratorCommandLogsService.selectConcentratorCommandLogsList(concentratorCommandLogs);
        return getDataTable(list);
    }

    /**
     * 导出集中器命令下发日志列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:concentratorcommandlogs:export')")
    @Log(title = "集中器命令下发日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConcentratorCommandLogs concentratorCommandLogs)
    {
        List<ConcentratorCommandLogs> list = concentratorCommandLogsService.selectConcentratorCommandLogsList(concentratorCommandLogs);
        ExcelUtil<ConcentratorCommandLogs> util = new ExcelUtil<ConcentratorCommandLogs>(ConcentratorCommandLogs.class);
        util.exportExcel(response, list, "集中器命令下发日志数据");
    }

    /**
     * 获取集中器命令下发日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:concentratorcommandlogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(concentratorCommandLogsService.selectConcentratorCommandLogsById(id));
    }

    /**
     * 新增集中器命令下发日志
     */
    @PreAuthorize("@ss.hasPermi('basedata:concentratorcommandlogs:add')")
    @Log(title = "集中器命令下发日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConcentratorCommandLogs concentratorCommandLogs)
    {
        return toAjax(concentratorCommandLogsService.insertConcentratorCommandLogs(concentratorCommandLogs));
    }

    /**
     * 修改集中器命令下发日志
     */
    @PreAuthorize("@ss.hasPermi('basedata:concentratorcommandlogs:edit')")
    @Log(title = "集中器命令下发日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConcentratorCommandLogs concentratorCommandLogs)
    {
        return toAjax(concentratorCommandLogsService.updateConcentratorCommandLogs(concentratorCommandLogs));
    }

    /**
     * 删除集中器命令下发日志
     */
    @PreAuthorize("@ss.hasPermi('basedata:concentratorcommandlogs:remove')")
    @Log(title = "集中器命令下发日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(concentratorCommandLogsService.deleteConcentratorCommandLogsByIds(ids));
    }
}
